home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / ViePratique / ArchiFacile / ArchiFacileSetup.exe / {app} / nw.pak / Unnamed File 001168.txt < prev    next >
Text File  |  2014-10-14  |  5KB  |  138 lines

  1. // Copyright (c) 2012 Intel Corp
  2. // Copyright (c) 2012 The Chromium Authors
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. //  in the Software without restriction, including without limitation the rights
  7. //  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co
  8. // pies of the Software, and to permit persons to whom the Software is furnished
  9. //  to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in al
  12. // l copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM
  15. // PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES
  16. // S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  17. //  OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH
  18. // ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. //  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20.  
  21. var argv, fullArgv, dataPath, manifest;
  22. var v8_util = process.binding('v8_util');
  23.  
  24. function App() {
  25. }
  26. require('util').inherits(App, exports.Base);
  27.  
  28. App.filteredArgv = [
  29.   /--no-toolbar/,
  30.   /--url=.*/,
  31.   /--remote-debugging-port=.*/,
  32.   /--renderer-cmd-prefix.*/,
  33. ];
  34.  
  35. App.prototype.quit = function() {
  36.   nw.callStaticMethod('App', 'Quit', [ ]);
  37. }
  38.  
  39. App.prototype.closeAllWindows = function() {
  40.   nw.callStaticMethod('App', 'CloseAllWindows', [ ]);
  41. }
  42.  
  43. App.prototype.crashBrowser = function() {
  44.   nw.callStaticMethod('App', 'CrashBrowser', [ ]);
  45. }
  46.  
  47. App.prototype.crashRenderer = function() {
  48.   nw.crashRenderer();
  49. }
  50.  
  51. App.prototype.setCrashDumpDir = function(dir) {
  52.   nw.setCrashDumpDir(dir); // for windows renderer process
  53.   return nw.callStaticMethodSync('App', 'SetCrashDumpDir', [ dir ]);
  54. }
  55.  
  56. App.prototype.clearCache = function() {
  57.   nw.callStaticMethodSync('App', 'ClearCache', [ ]);
  58. }
  59.  
  60. App.prototype.getProxyForURL = function (url) {
  61.   return nw.callStaticMethodSync('App', 'getProxyForURL', [ url ]);
  62. }
  63.  
  64. App.prototype.addOriginAccessWhitelistEntry = function(sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains) {
  65.     return nw.callStaticMethodSync('App', 'AddOriginAccessWhitelistEntry', sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains);
  66. }
  67.  
  68. App.prototype.removeOriginAccessWhitelistEntry = function(sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains) {
  69.     return nw.callStaticMethodSync('App', 'RemoveOriginAccessWhitelistEntry', sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains);
  70. }
  71.  
  72. App.prototype.registerGlobalHotKey = function(shortcut) {
  73.   if (v8_util.getConstructorName(shortcut) != "Shortcut")
  74.     throw new TypeError("Invaild parameter, need Shortcut object.");
  75.  
  76.   return nw.callStaticMethodSync('App',
  77.                                  'RegisterGlobalHotKey',
  78.                                  [ shortcut.id ])[0];
  79. }
  80.  
  81. App.prototype.unregisterGlobalHotKey = function(shortcut) {
  82.   if (v8_util.getConstructorName(shortcut) != "Shortcut")
  83.     throw new TypeError("Invaild parameter, need Shortcut object.");
  84.  
  85.   nw.callStaticMethodSync('App', 'UnregisterGlobalHotKey', [ shortcut.id ]);
  86. }
  87.  
  88. App.prototype.__defineGetter__('argv', function() {
  89.   if (!argv) {
  90.     var fullArgv = this.fullArgv;
  91.     argv = [];
  92.     for (var i = 0; i < fullArgv.length; ++i) {
  93.       var matched = false;
  94.       for (var j = 0; j < App.filteredArgv.length; ++j) {
  95.         if (App.filteredArgv[j].test(fullArgv[i])) {
  96.           matched = true;
  97.           break;;
  98.         }
  99.       }
  100.       if (matched)
  101.         continue;
  102.  
  103.       argv.push(fullArgv[i]);
  104.     }
  105.   }
  106.  
  107.   return argv;
  108. });
  109.  
  110. App.prototype.__defineGetter__('fullArgv', function() {
  111.   if (!fullArgv)
  112.     fullArgv = nw.callStaticMethodSync('App', 'GetArgv', [ ]);
  113.  
  114.   return fullArgv;
  115. });
  116.  
  117. App.prototype.__defineGetter__('dataPath', function() {
  118.   if (!dataPath)
  119.     dataPath = nw.callStaticMethodSync('App', 'GetDataPath', [ ])[0];
  120.  
  121.   return dataPath;
  122. });
  123.  
  124. App.prototype.__defineGetter__('manifest', function() {
  125.   if (!manifest) {
  126.     manifest = JSON.parse(
  127.         nw.callStaticMethodSync('App', 'GetPackage', [ ])[0]);
  128.   }
  129.   return manifest;
  130. });
  131.  
  132. // Store App object in node's context.
  133. if (process['_nw_app']) {
  134.   exports.App = process['_nw_app'];
  135. } else {
  136.   exports.App = process['_nw_app'] = new App();
  137. }
  138.